<#if Session.user.rolekind==2 > 
<table width="100%" height="100px">
	<tr><td>
		<table width="100%" border=1 bgcolor="#ffffff">
			<tbody><tr><td><h4>权限类型分配操作</h4></td></tr></tbody>
		 	<tr><td>请选择要分配的权限类型<div id="div.authkind.setter"/></td></tr>
		 	<tr><td align="center"><input type="button" id="auth.save.setter" name="auth.save.setter" value="确定"></td></tr>
		 </table>
		 
		</td>
	    <td valign="top">
	    	该节点已拥有的权限<span><a href="#" id="auth.del" name="auth.del">删除</a></span> 
		 	<div id="div.authkindhave.setter">
		</td>
 	</tr>
</table>
 

<script type="text/javascript">
var dataURL = '/data/sc.action';//取数据的url

//-------------填充权限类型 
var authkindsetter=null;
var authkindsetter_pageno = 1;
if (authkindsetter) { authkindsetter_pageno = authkindsetter.findCurrentPage(); }

var loadAuthKindSetterList = function(){
	var columns = [{text:'权限代号',name:'kind'},{text:'权限类型',name:'name'}];//要显示的字段
	var dataURLParams = {"scid":"authkind_1"};
	if (!authkindsetter){
		authkindsetter = new MUI.List({
			instanceName: 'authkindsetter',
	       	container:'div.authkind.setter',
	       	showCheckBox:true,
			showCommand:false,
	       	id: "authkindsetterList",
	       	columns:columns,
	       	dataURL:dataURL,
	       	dataURLParams: dataURLParams,
	       	cbName: 'idsauthkindsetter',
	       	saveCheck:true,
	       	commands:[]
	   	});//MUI.List
   	}
   	authkindsetter.setDataURLParams(dataURLParams);
   	authkindsetter_pageno = 1;
   	authkindsetter.findList(authkindsetter_pageno);
}


//填充已拥有的权限类型
var authhavesetter=null;
var authhavesetter_pageno = 1;
if (authhavesetter) { authhavesetter_pageno = authhavesetter.findCurrentPage(); }

var loadAuthhaveSetterList = function(){
	var columns="";
	var dataURLParams = "";
	columns = [{text:'选择',name:'id',align:'center'},{text:'编号',name:'id'},{text:'权限类型',name:'kindname'}];//要显示的字段
	dataURLParams = {"scid":"authkindsetter", "authid":nodeinfo.id};
	if (!authhavesetter){
		authhavesetter = new MUI.List({
			instanceName: 'authhavesetter',
	       	container:'div.authkindhave.setter',
	       	showCheckBox:true,
			showCommand:false,
	       	id: "authhavesetterList",
	       	columns:columns,
	       	dataURL:dataURL,
	       	dataURLParams: dataURLParams,
	       	cbName: 'idsauthhavesetter',
	       	saveCheck:true,
	       	commands:[]
	   	});//MUI.List
   	}
   	authhavesetter_pageno = 1;
   	authhavesetter.findList(authhavesetter_pageno);
}



window.addEvent('domready', function() {
	new MUI.Require({
	  js: [MUI.path.plugins + 'mochaList/List.js'],
	  onload: function(){
		if(nodeinfo==null){
			MUI.notification('<font color=red>错误：</font> 未取得节点信息 ');
			return;
		}
		loadAuthKindSetterList();
		loadAuthhaveSetterList();
	  } 
	}); 
	
	
	$('auth.save.setter').addEvent('click', function(e){
		if( !authkindsetter) return;
		var dataURLParams = ""; 
		var checkids_kinds_setter = authkindsetter.getcurCheckIds();
		checkids_kinds_setter = checkids_kinds_setter + "";
		if(null==checkids_kinds_setter || ""==checkids_kinds_setter) { alert('必须选择一项要添加的权限种类'); return; }
		 
		dataURLParams = {"scid":"authkindsetter_add", "checkids_kinds_setter":checkids_kinds_setter, 
				"authid":nodeinfo.id};
		authkindsetter.clearCheckIds();
		try {
			var request = new Request.JSON({
			url: dataURL,
			onComplete: function(json,text) {
				if (json.error.errorcode==0){
    				MUI.notification('添加成功！');
    				loadAuthhaveSetterList();
    				//取消所有选中的勾选
    				authkindsetter.cancelAll();
    			}else{
    				MUI.notification('<font color=red>错误：</font>('+json.error.retstring+')');
    			}
			}
		}).get(dataURLParams);
		} catch (ex) {
			MUI.notification('<font color=red>错误：</font>('+json.error.retstring+')');
		}
	});
	
	$('auth.del').addEvent('click', function(e){
		if(!authhavesetter) return;
		checkids_authhave_setter = authhavesetter.getcurCheckIds();
		if(null==checkids_authhave_setter || ""==checkids_authhave_setter) { alert('必须选择一项要删除的权限类型'); return; }
		checkids_authhave_setter = checkids_authhave_setter + "";
		authhavesetter.clearCheckIds();
		var dataURLParams = {"scid":"authkindsetter_del", "authkind":nodeinfo.kind, "checkids_authhave_setter":checkids_authhave_setter};
		try {
			var request = new Request.JSON({
			url: dataURL,
			onComplete: function(json,text) {
				if (json.error.errorcode==0){
    				MUI.notification('删除成功！');
    				loadAuthhaveSetterList();
    				//取消所有选中的勾选
    				authhavesetter.cancelAll();
    			}else{
    				MUI.notification('<font color=red>错误：</font>('+json.error.retstring+')');
    			}
			}
		}).get(dataURLParams);
		} catch (ex) {
			MUI.notification('<font color=red>错误：</font>('+json.error.retstring+')');
		}
	});
});
</script>
<#else>
您无权访问该页面！
</#if>